//
//  YAYISettingCell.m
//  YAYIDoctor
//
//  Created by Veer on 16/5/6.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYISettingCell.h"

#import "YAYISettingItemModel.h"

@interface YAYISettingCell()

@end


@implementation YAYISettingCell


- (void)setIsShowSignal:(BOOL)isShowSignal
{
    _isShowSignal = isShowSignal;
    
    self.tipLbl.hidden = !isShowSignal;
}


- (void)setModel:(YAYISettingItemModel *)model
{
    _model = model;
    
    //
    if (model.icon) {
        self.imageView.image = [UIImage imageNamed:model.icon];
    }
    
    self.textLabel.text = model.name;
    
    if (model.detail) {
        self.tipLbl.text = model.detail;
    }
    
    self.isShowSignal = model.isShowSignal;
}


+ (instancetype)cellWith:(UITableView *)tablevie
{
    static NSString *cellID = @"settingCell";
    
    YAYISettingCell *cell = [tablevie dequeueReusableCellWithIdentifier:cellID];
    
    if (nil == cell) {
        cell = [[YAYISettingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        // lieview
        [self setupSubView];
        
    }
    return self;
}


- (void)setupSubView
{
    self.textLabel.font = [UIFont systemFontOfSize:17];
    self.textLabel.textColor = YAYIColor(93, 90, 93);
    
    // detail
    UILabel *tipLbl = [[UILabel alloc] init];
    tipLbl.textColor = YAYIColor(250, 70, 74);
    tipLbl.font = [UIFont systemFontOfSize:13];
    tipLbl.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:tipLbl];
    self.tipLbl = tipLbl;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.tipLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-5);
        make.centerY.equalTo(self.contentView);
    }];
}



@end
